import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(home: AnimateOpacityPage());
  }
}

class AnimateOpacityPage extends StatefulWidget {
  @override
  _AnimateOpacityPageState createState() => _AnimateOpacityPageState();
}

class _AnimateOpacityPageState extends State<AnimateOpacityPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('动画示例')),
      body: SizedBox.expand(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            AnimatedOpacity(
              opacity: 0.5,
              duration: Duration(seconds: 1),
              child: Container(
                color: Colors.red,
                width: 200,
                height: 200,
                child: Text("早起的年轻人"),
              ),
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {},
        child: Icon(Icons.change_circle),
      ),
    );
  }
}
